

package com.hexinfo.dmpro.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.http.ResponseEntity;
import com.hexinfo.dmpro.admin.model.SysDictDetail;
import com.hexinfo.dmpro.admin.service.SysDictDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 字典子表
 *
 * @author zhouax
 * @date 2023-08-10 20:33:33
 */
@RestController
@AllArgsConstructor
@RequestMapping("/sysdictdetail" )
@Api(value = "sysdictdetail", tags = "字典子表管理")
public class SysDictDetailController {

    private final  SysDictDetailService sysDictDetailService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param sysDictDetail 字典子表
     * WrapperEnhancer.like(sysDictDetail); //自动拼接存在值sql的方法
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    public ResponseEntity<Object> getSysDictDetailPage(Page page, SysDictDetail sysDictDetail) {
        return ResponseEntity.ok(sysDictDetailService.queryList(page,sysDictDetail));
    }


    /**
     * 通过id查询字典子表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    public ResponseEntity<Object> getById(@PathVariable("id" ) Long id) {
        return ResponseEntity.ok(sysDictDetailService.getById(id));
    }

    /**
     * 新增字典子表
     * @param sysDictDetail 字典子表
     * @return R
     */
    @ApiOperation(value = "新增字典子表", notes = "新增字典子表")
    @PostMapping
    public ResponseEntity<Object> save(@RequestBody SysDictDetail sysDictDetail) {
        return ResponseEntity.ok(sysDictDetailService.save(sysDictDetail));
    }

    /**
     * 修改字典子表
     * @param sysDictDetail 字典子表
     * @return R
     */
    @ApiOperation(value = "修改字典子表", notes = "修改字典子表")
    @PutMapping
    public ResponseEntity<Object> updateById(@RequestBody SysDictDetail sysDictDetail) {
        return ResponseEntity.ok(sysDictDetailService.updateById(sysDictDetail));
    }

    /**
     * 通过id删除字典子表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除字典子表", notes = "通过id删除字典子表")
    @DeleteMapping("/{id}" )
    public ResponseEntity<Object> removeById(@PathVariable Long id) {
        return ResponseEntity.ok(sysDictDetailService.removeById(id));
    }

}
